package com.zr.serviceimpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.ShowMyInfoDao;
import com.zr.model.Cuser;
import com.zr.service.ShowMyInfoService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Service("showMyInfoService")
public class ShowMyInfoServiceImpl<T> implements ShowMyInfoService<T>{

	@Resource
	private ShowMyInfoDao<T> showMyInfoDao;
	
	@Override
	public JSONObject getMyInfo(int uid,int page,int rows) {
		JSONObject j = new JSONObject();
		j.put("total", 1);
		List<Cuser> us = showMyInfoDao.getMyInfoByUid(page, rows, uid);
		JSONArray js = new JSONArray();
		for (Cuser uu : us) {
			JSONObject u = new JSONObject();
			u.put("uid", uu.getUid());
			u.put("uname", uu.getUname());
			u.put("utel", uu.getUtel());
			u.put("ustate", uu.getUstate());
			u.put("rname", uu.getCrole().getRname());
			u.put("uroot", uu.getUroot());
			u.put("upassword", uu.getUpassword());
			js.add(u);
		}
		j.put("rows", js);
		return j;
	}

}
